}
curpos += ehdr.e_phnum * sizeof(Elf_Phdr);
-
+ /* Copy kernel .text .data .bss segments into physical memory */
for (h = 0; h < ehdr.e_phnum; h++) {
if (phdr[h].p_type != PT_LOAD ||
(phdr[h].p_flags & (PF_W|PF_X)) == 0)
maxva += sizeof(Elf_Ehdr) + ehdr.e_shnum * sizeof(Elf_Shdr);
maxva = (maxva + ELFROUND - 1) & ~(ELFROUND - 1);
+ /* Copy kernel string / symbol tables into physical memory */
for (h = 0; h < ehdr.e_shnum; h++) {
if (shdr[h].sh_type == SHT_STRTAB) {
for (i = 0; i < ehdr.e_shnum; i++)
break;
if (i == ehdr.e_shnum) {
shdr[h].sh_offset = 0;
- continue;
+ continue; /* Skip string tables which are not for symbol tables */
}
}
}
curpos = shdr[h].sh_offset;
- shdr[h].sh_offset = maxva - *symtab_addr;
+ shdr[h].sh_offset = maxva - *symtab_addr; /* Mangled to be based on ELF header location */
DPRINTF(("copy section %d, size 0x%x\n", h, shdr[h].sh_size));
for (i = 0; i < shdr[h].sh_size; i += c, maxva += c) {
maxva = (maxva + ELFROUND - 1) & ~(ELFROUND - 1);
}
- shdr[h].sh_name = 0;
+ shdr[h].sh_name = 0; /* Name is NULL */
}
if (*symtab_len == 0) {
memcpy(p + sizeof(int), &ehdr, sizeof(Elf_Ehdr));
*(int *)p = maxva - *symtab_addr;
+ /* Copy total length, crafted ELF header and section header table */
s = sizeof(int) + sizeof(Elf_Ehdr) + ehdr.e_shnum * sizeof(Elf_Shdr);
for (i = 0; i < s; i += c, symva += c) {
c = PAGE_SIZE - (symva & (PAGE_SIZE - 1));
* are also present in the initial GDT, many OSes will be able to avoid
* installing their own GDT.
*/
-#define FLAT_RING1_CS 0x0819
-#define FLAT_RING1_DS 0x0821
-#define FLAT_RING3_CS 0x082b
-#define FLAT_RING3_DS 0x0833
+#define FLAT_RING1_CS 0x0819 /* GDT index 259 */
+#define FLAT_RING1_DS 0x0821 /* GDT index 260 */
+#define FLAT_RING3_CS 0x082b /* GDT index 261 */
+#define FLAT_RING3_DS 0x0833 /* GDT index 262 */
/*